
// 原来的open方法
var rawOpen = XMLHttpRequest.prototype.open;
// 重写open方法
XMLHttpRequest.prototype.open = function () {
    rawOpen.apply(this, arguments)

    // 自定义请求头（需要在open方法后调用）
    try {
        // this.setRequestHeader('X-ENV', window.env || 'product');
        this.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
        this.setRequestHeader('Cache-Control', 'no-cache');
        if (localStorage.token) {
            this.setRequestHeader('token', localStorage.token);
        }

        if (localStorage.userid) {
            this.setRequestHeader('x-sf-userid', localStorage.userid);
        }

    } catch (e) {
        console.error('e', e)
    }
};
